//
//  LSPageWebVC.m
//  HappyStore
//
//  Created by 陈锋 on 16/9/6.
//  Copyright © 2016年 LLJ. All rights reserved.
//

#import "LSPageWebVC.h"

@interface LSPageWebVC ()<NJKWebViewProgressDelegate,UIWebViewDelegate>
//进度条
@property (strong, nonatomic)NJKWebViewProgressView *progressView;
@property (strong, nonatomic)NJKWebViewProgress *progressProxy;
@end

@implementation LSPageWebVC

- (void)viewDidLoad {
    [super viewDidLoad];
    NSURL *url = [NSURL URLWithString:self.url_out];
    
    NSURLRequest *request = [NSURLRequest requestWithURL:url];
    [self.webView loadRequest:request];
    
    //添加进度条
    _progressProxy= [[NJKWebViewProgress alloc] init];
    self.webView.delegate = _progressProxy;
    _progressProxy.webViewProxyDelegate = self;
    _progressProxy.progressDelegate = self;
    
    CGFloat progressBarHeight = 2.f;
    CGRect barFrame = CGRectMake(0, 18, screenW, progressBarHeight);
    _progressView = [[NJKWebViewProgressView alloc] initWithFrame:barFrame];
    _progressView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleTopMargin;
    // 添加进度条
    [self.view addSubview:_progressView];
    
}

#pragma mark - NJKWebViewProgressDelegate
-(void)webViewProgress:(NJKWebViewProgress *)webViewProgress updateProgress:(float)progress
{
    [_progressView setProgress:progress animated:YES];
}

- (void)setupWebViewWithTabBarFrame
{
    self.webView.size = [UIScreen mainScreen].bounds.size;
    self.webView.x = 0;
    self.webView.y = 54;
    self.webView.height = screenH;
}

- (void)setupWebViewNoTabBarFrame
{
    self.webView.size = [UIScreen mainScreen].bounds.size;
    self.webView.x = 0;
    self.webView.y = 54;
    self.webView.height = screenH - 54;
}
- (IBAction)closeView:(UIButton *)sender {
    
    [self dismissViewControllerAnimated:YES completion:nil];
    
}
@end
